package config;

import admin.Admin;
import admin.AdminController;
import admin.Config;
import admin.Menu;
import admin.Role;
import admin.RoleMenu;

import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.kit.PropKit;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.c3p0.C3p0Plugin;
import com.jfinal.render.ViewType;


public class CommonConfig extends JFinalConfig {
	public void configConstant(Constants me) {
		PropKit.use("socket.properties");
		me.setDevMode(PropKit.getBoolean("devMode", false));
		me.setViewType(ViewType.JSP);
		me.setBaseDownloadPath("d:/declaimer");
		me.setBaseUploadPath("d:/declaimer");
		me.setMaxPostSize(200 * 1024 * 1024);
	}

	public void configRoute(Routes me) {
		me.add("/", CommonController.class);
//		me.add("/Systems", Systems.SystemController.class);
		me.add("/admin", AdminController.class);
//		me.add("/device", DeviceController.class);
//		me.add("/material", MaterialController.class);
//		me.add("/activity", ActivityController.class);
//		me.add("/readtype", ReadTypeController.class);
//		me.add("/read", ReadController.class);
//		me.add("/user", UserController.class);
//		me.add("/usercenter", UserCenterController.class);
		// me.add("/declaimer", DeclaimerController2.class);//可能是本地录制的
//		me.add("/declaimer", DeclaimerController.class);// 阿里云
//		me.add("/wechat", WechatController.class);
//
//		me.add("/test",HttpConnectionUtil.class);
//		me.add("/upload2", fdg.class);
//		me.add("/getF", getFiles.class);
//		me.add("/upload3", UploadController.class);
	}

	public void configPlugin(Plugins me) {
		C3p0Plugin c3p0Plugin = new C3p0Plugin(PropKit.get("jdbcUrl"), PropKit.get("user"),
				PropKit.get("password").trim());
		c3p0Plugin.setMaxPoolSize(500);  //设置数据库最大连接数
		me.add(c3p0Plugin);
		ActiveRecordPlugin arp = new ActiveRecordPlugin(c3p0Plugin);
		me.add(arp);
		arp.addMapping("admin", Admin.class);
		arp.addMapping("menu", Menu.class);
		arp.addMapping("role", Role.class);
		arp.addMapping("role_menu", RoleMenu.class);
		arp.addMapping("config", Config.class);
//		arp.addMapping("activity", Activity.class);
//		arp.addMapping("device", Device.class);
//		arp.addMapping("material", Material.class);
//		arp.addMapping("materialtype", MaterialType.class);
//		arp.addMapping("materialpic", MaterialPic.class);
//		arp.addMapping("music", Music.class);
//		arp.addMapping("readtype", ReadType.class);
//		arp.addMapping("read_", Read.class);
//		arp.addMapping("scard", Scard.class);
//		arp.addMapping("user", User.class);
//		arp.addMapping("wx_ticket", WxTicket.class);
	}

	public void configInterceptor(Interceptors me) {
	}

	public void configHandler(Handlers me) {
	}
}
